// Package sys
// @Link  https://github.com/bufanyun/hotgo
// @Copyright  Copyright (c) 2025 HotGo CLI
// @Author  Ms <133814250@qq.com>
// @License  https://github.com/bufanyun/hotgo/blob/master/LICENSE
// @AutoGenerate Version 2.15.11
package sys

import (
	"context"
	"hotgo/api/admin/storemember"
	"hotgo/internal/model/input/sysin"
	"hotgo/internal/service"
)

var (
	StoreMember = cStoreMember{}
)

type cStoreMember struct{}

// List 查看门店账号管理列表
func (c *cStoreMember) List(ctx context.Context, req *storemember.ListReq) (res *storemember.ListRes, err error) {
	list, totalCount, err := service.SysStoreMember().List(ctx, &req.StoreMemberListInp)
	if err != nil {
		return
	}

	if list == nil {
		list = []*sysin.StoreMemberListModel{}
	}

	res = new(storemember.ListRes)
	res.List = list
	res.PageRes.Pack(req, totalCount)
	return
}

// Export 导出门店账号管理列表
func (c *cStoreMember) Export(ctx context.Context, req *storemember.ExportReq) (res *storemember.ExportRes, err error) {
	err = service.SysStoreMember().Export(ctx, &req.StoreMemberListInp)
	return
}

// Edit 更新门店账号管理
func (c *cStoreMember) Edit(ctx context.Context, req *storemember.EditReq) (res *storemember.EditRes, err error) {
	err = service.SysStoreMember().Edit(ctx, &req.StoreMemberEditInp)
	return
}

// View 获取指定门店账号管理信息
func (c *cStoreMember) View(ctx context.Context, req *storemember.ViewReq) (res *storemember.ViewRes, err error) {
	data, err := service.SysStoreMember().View(ctx, &req.StoreMemberViewInp)
	if err != nil {
		return
	}

	res = new(storemember.ViewRes)
	res.StoreMemberViewModel = data
	return
}

// Delete 删除门店账号管理
func (c *cStoreMember) Delete(ctx context.Context, req *storemember.DeleteReq) (res *storemember.DeleteRes, err error) {
	err = service.SysStoreMember().Delete(ctx, &req.StoreMemberDeleteInp)
	return
}

// Switch 更新门店账号管理开关状态
func (c *cStoreMember) Switch(ctx context.Context, req *storemember.SwitchReq) (res *storemember.SwitchRes, err error) {
	err = service.SysStoreMember().Switch(ctx, &req.StoreMemberSwitchInp)
	return
}